package genetics;

import genetics.HaploidAttribute;

/**
 * Phenotype
 * @author Nicolas Winkler
 *
 */
public class DiploidAttribute {
	/**
	 * the first haploid attribute describing
	 */
	public HaploidAttribute a;
	public HaploidAttribute b;

	public DiploidAttribute(HaploidAttribute a, HaploidAttribute b) {
		this.a = a;
		this.b = b;
	}

	public HaploidAttribute haploidize() {
		if (Math.random() > 0.5)
			return a.mitosis();
		else
			return b.mitosis();
	}

	public HaploidAttribute getPhenotype() {
		if (a.dominantRecessive == HaploidAttribute.HaploidisizeType.DOMINANT) {
			return a;
		}
		else if (b.dominantRecessive == HaploidAttribute.HaploidisizeType.DOMINANT) {
			return b;
		}
		else if (b.dominantRecessive == HaploidAttribute.HaploidisizeType.INTERMEDIARY) {
			return a.intermediary(b);
		}
		else {
			return a;
		}
	}

	public String getDescription() {
		return a.getDescription();
	}
}
